﻿Public Class DtpoTechoPropio
    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String) As List(Of EtpoTechoPropio)
        Dim tpoTechoPropios As List(Of EtpoTechoPropio) = Nothing

        Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings(descEmpresa).ConnectionString)
            Using cmd As New SqlCommand("usp_tpoTechoPropio_sel", cn)
                cmd.CommandType = CommandType.StoredProcedure
                Try
                    cn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult Or CommandBehavior.CloseConnection)
                        If dr.HasRows Then
                            tpoTechoPropios = New List(Of EtpoTechoPropio)
                            Dim tpoTechoPropio As EtpoTechoPropio = Nothing
                            Do While dr.Read
                                tpoTechoPropio = New EtpoTechoPropio( _
                                    dr.GetInt32(dr.GetOrdinal("idTipoTP")), _
                                    dr.GetString(dr.GetOrdinal("descTipoTP")), _
                                    dr.GetString(dr.GetOrdinal("estado")), _
                                    dr.GetInt32(dr.GetOrdinal("idUsuario")))
                                tpoTechoPropios.Add(tpoTechoPropio)
                            Loop
                            dr.Close()
                        End If
                    End Using
                Catch ex As Exception
                    Throw
                End Try
            End Using
        End Using

        Return tpoTechoPropios
    End Function
End Class
